package com.whsxt.service.impl;


import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.whsxt.common.PageInfo;
import com.whsxt.common.ResultData;
import com.whsxt.domain.Bills;
import com.whsxt.domain.SearchData;
import com.whsxt.mapper.BillsMapper;
import com.whsxt.service.IBillsService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 贺炯
 * @since 2019-09-18
 */
//@Service
@Service
public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements IBillsService {

	@Override
	public Object selectAll(String limit, String page, SearchData searchData) {
		Long limit1 = Long.valueOf(limit);
		Long page1 = Long.valueOf(page);
		QueryWrapper<Bills> wrapper = new QueryWrapper<Bills>();
		wrapper.eq(searchData.getType()!=null&&searchData.getType()!=0,"type_id", searchData.getType());
		wrapper.gt(searchData.getStartTime()!=null&&!searchData.getStartTime().equals(""),"bill_time", searchData.getStartTime());
		wrapper.lt(searchData.getEndTime()!=null&&!searchData.getEndTime().equals(""),"bill_time", searchData.getEndTime());
		IPage<Bills> page2 = this.page(new Page<Bills>(page1, limit1), wrapper);
		PageInfo pageInfo = new PageInfo(page2.getTotal(), page2.getRecords());
		ResultData resultData = new ResultData(pageInfo);
		return resultData;
	}

}
